<!--
 * @Author: your name
 * @Date: 2019-11-19 09:54:43
 * @LastEditTime: 2019-11-22 16:15:41
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \YouYouFo\you-you-go\src\views\news\NewsList.vue
 -->

<template>
  <div>
    <!-- <p>新闻资讯</p>
    <router-link to="/newsDetail">跳转到新闻详情</router-link>-->
    <van-row v-for="(item, index) in newslist" :key="index" @click="newsDetail(item.id)">
      <van-col span="4">
        <van-image width="100" height="100" :src="item.img_url" />
      </van-col>
      <van-col span="15" offset="3">
        <h3>{{item.zhaiyao}}</h3>
        <p class="margin-style">
          <span>发表时间:{{item.add_time.substr(0,10)}}</span>
          <span>点击:{{item.click}}</span>
        </p>
      </van-col>
    </van-row>
  </div>
</template>
        
<script>
import { getNewsList } from '../../api/index'
export default {
  data() {
    return {
      newslist: []
    }
  },
  methods: {
    // 获取新闻列表
    async getNewsList() {
      const { data: res } = await getNewsList()
      console.log(res, 233)
      this.newslist = res.message
    },
    // 跳转到详情页
    newsDetail(ids) {
      // console.log(ids,35);
      this.$router.push(`/newsDetail/${ids}`)
    }
  },
  created() {
    this.getNewsList()
  }
}
</script>
<style scoped>
.van-row {
  padding: 10px 0 15px 10px;
  border-bottom: 1px solid #ccc;
}
.margin-style {
  display: flex;
  color: #65aae2;
  justify-content: space-between;
}
</style>